﻿using Bandit.Helpers;
using Bandit.UI.MVVM;
using ETC.HallICElan2In1.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ETC.HallICElan2In1.ViewModels
{
    public class MainViewModel : NotifyObject
    {
        #region TestInfo
        /// <summary>
        /// Test Information
        /// </summary>
        public TestInfo TestInfo { get; private set; }
        #endregion

        /// <summary>
        /// Test Config
        /// </summary>
        public Core.TestConfig TestConfig
        {
            get
            {
                return Core.TestConfig.Instance;
            }
        }

        #region Setting
        /// <summary>
        /// Setting
        /// </summary>
        public Setting Setting { get { return App.SettingViewModel.Setting; } }
        #endregion

        #region IsEngineer
        private bool _IsEngineer;
        /// <summary>
        /// IsEngineer
        /// </summary>
        public bool IsEngineer
        {
            get { return _IsEngineer; }
            set
            {
                _IsEngineer = value;
                OnPropertyChanged("IsEngineer");
            }
        }
        #endregion

        #region OnClick
        /// <summary>
        /// Click Event
        /// </summary>
        public ICommand OnClick { get; set; }
        #endregion

        #region Status

        /// <summary>
        /// 状态
        /// </summary>
        public Status Status { get; set; }

        #region 更新状态
        /// <summary>
        /// 更新MES状态
        /// </summary>
        /// <param name="status"></param>
        /// <param name="statusBrush"></param>
        public void UpdateStatus(string status, string statusToolTip = null, MyBrushes statusBrush = MyBrushes.White)
        {
            this.Status.Text = status;

            this.Status.Color = statusBrush.ToBrushString();
        }
        #endregion

        #endregion

        #region UsbStatus

        /// <summary>
        /// Usb状态
        /// </summary>
        public Status UsbStatus { get; set; }

        #endregion

        #region Hall1 Status
        private Status _HallStatus1;

        public Status HallStatus1
        {
            get { return _HallStatus1; }
            set
            {
                _HallStatus1 = value;
                OnPropertyChanged(nameof(HallStatus1));
            }
        }

        private Status _HallStatus2;

        public Status HallStatus2
        {
            get { return _HallStatus2; }
            set
            {
                _HallStatus2 = value;
                OnPropertyChanged(nameof(HallStatus2));
            }
        }

        #endregion

        //#region EnabledStartButton
        //private bool _EnabledStartButton;
        ///// <summary>
        ///// 启用为工程师模式
        ///// </summary>
        //public bool EnabledStartButton
        //{
        //    get { return _EnabledStartButton; }
        //    set
        //    {
        //        _EnabledStartButton = value;
        //        OnPropertyChanged("EnabledStartButton");
        //    }
        //}
        //#endregion

        #region EngineerMode
        private bool _EngineerMode;
        /// <summary>
        /// 启用为工程师模式
        /// </summary>
        public bool EngineerMode
        {
            get { return _EngineerMode; }
            set
            {
                _EngineerMode = value;
                OnPropertyChanged("EngineerMode");
            }
        }
        #endregion

        #region Constructors[构造函数]

        public MainViewModel()
        {
            this.TestInfo = new TestInfo();

            this.Status = new Status(App.GetString("Ready"), MyBrushes.White);

            this.UsbStatus = new Status(App.GetString("Serial is not connected!"), MyBrushes.Red);

            this.HallStatus1 = new Status(App.GetString("Ready"), MyBrushes.RichBlue);

            this.HallStatus2 = new Status(App.GetString("Ready"), MyBrushes.White);
        }

        #endregion
    }
}
